home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / x_lisp / xlispshl / lispshel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  11.1 KB  |  347 lines

  1. /********************************************************************/
  2. /*                                                                   */
  3. /*                       XLISPshell                                 */
  4. /*                     <c> Dr. Sarnow                                */
  5. /*                 für die PD der ST-Computer                        */
  6. /*               zum persönlichen Gebrauch freigegeben                */
  7. /*                                                                    */
  8. /********************************************************************/
  9.  
  10. #include <obdefs.h>    
  11. #include <gemdefs.h>
  12. #include <osbind.h>
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include "lispshel.h"
  16.  
  17. #define TRUE (1)
  18. #define FALSE (0)
  19. #define DEBUG            
  20.  
  21. /*************************** idiotisches GEM Geblasel **************/            
  22. int contrl[12],
  23.     intin[128],
  24.     intout[128],
  25.     ptsin[128],
  26.     ptsout[128] ;
  27.  
  28. int work_in[12],
  29.     work_out[57] ;
  30. int pxyarray[10] ;
  31.  
  32. int handle ;
  33. OBJECT *menu_tree,*formular,*urheber,*optfiles;
  34.  
  35. int mouse ;             /* mouse ein = 1, aus = 0             */
  36. int gl_dummy ;       /* globaler dummy */
  37. int dix,diy,diw,dih ; /* dialog box parameter */
  38. int x_info,y_info,w_info,h_info;
  39. int x_opt,y_opt,w_opt,h_opt;
  40. int obval;
  41. int xwork,ywork,wwork,hwork;
  42. int xfull,yfull,wfull,hfull;
  43.  
  44. int msgbuff[32] ;
  45.  
  46. char options[7][20],d[20],lspfile[20],was[30],akt[13],pf[150],*xlopt;
  47.  
  48.  
  49. /* globale Variablen für den Gebrauch  der Window Routinen aus der */
  50. /* MEGAMAX Tool Diskette Nr. 4*/
  51.  
  52. static int whandle[5] ; /* window-handle fuer max. 4 fenster */
  53. static int ax[5],ay[5],aw[5],ah[5] ;  /* koord. der arbeitsbereiche */
  54. static int bx[5],by[5],bw[5],bh[5] ;  /* koord. der bildbereiche */
  55. static int posx[5],posy[5] ; /* koord. des linken oberen eckpkts */
  56.                       /*  im virtuellen fenster */
  57. static int fulled[5] ; /* fenster fulled oder nicht */
  58. static int wikind[5] ; /* fensterattribute */
  59. static int wopen[5] ; /* fenster offen oder zu */
  60. static char *speich[5] ; /* anfangsadressen der speicherbereiche */
  61. static char *base[5] ; /* anfangsadressen der screens */
  62. static int maxwd ;     /* nummer des hoechsten windows muss zu anfang auf 0
  63.                    gesetzt werden */
  64. static char *bild ;
  65. static int mwidth,mheight,mplane ;
  66. static int wd_handle ;
  67.  
  68. /************** Öffnet virtuelle Arbeitstation ************/
  69.  
  70. open_vwork()
  71. {
  72.  int i,dummy;
  73.   appl_init();
  74.   handle=graf_handle(&gl_dummy,&gl_dummy,&gl_dummy,&gl_dummy);
  75.   for (i=0;i<10;work_in[i++]=1);
  76.   work_in[10]=2;
  77.   v_opnvwk(work_in,&handle,work_out);
  78.   graf_mouse(0,&gl_dummy) ;
  79. }
  80.  
  81. /******************* Schließt dieselbe  *********************/
  82.  
  83. close_vwork()
  84. {
  85.  v_clsvwk(handle);
  86.  appl_exit();
  87.  Pterm0();
  88. }
  89.  
  90. /********************** Maus an *****************************/
  91.  
  92. show_mouse()
  93. { if (!mouse)
  94.   { graf_mouse(257,&gl_dummy) ;
  95.     mouse = TRUE ;
  96.   }
  97. }
  98.  
  99. /*************** Und wieder aus ********************************/
  100.  
  101. hide_mouse()
  102. { if (mouse)
  103.   { graf_mouse(256,&gl_dummy) ;
  104.     mouse = FALSE ;
  105.   }
  106. }
  107.  
  108. /*************************************************************/
  109. /*    hauptprogramm                                          */
  110. /*************************************************************/
  111.  
  112. main()
  113. {
  114.   int reso ;
  115.   open_vwork() ;
  116.   if (!rsrc_load("lispshel.rsc"))
  117.   {
  118.     form_alert(1,"[3][Ich kann LISPSHEL.RSC nicht finden !][Abbruch]");
  119.     close_vwork();
  120.   }
  121.   if (!rsrc_gaddr(0,LEISTE,&menu_tree))
  122.   {
  123.     form_alert(1,"[3][Resource File nicht ok !][Abbruch]");
  124.     close_vwork();
  125.   }
  126.  
  127.   if (!Getrez()==2)
  128.   {
  129.      form_alert(1,"[3]['tschuldigung,|funktioniert nur|mit hoher|Auflösung.][ Meinetwegen ]");
  130.      exit(0);
  131.   }
  132.  
  133.   /* variablen setzen */
  134.  
  135.   mouse = TRUE ; /*Maus an*/
  136.   xlopt=malloc(310); /*Speicherplatz für Hilfsstring bereitstellen*/
  137.   strcpy(pf,"A:\\*.*"); /*Setze Pfad String auf das*/
  138.   *pf=Dgetdrv()+65;     /*aktuelle Laufwerk*/
  139.   menu_bar(menu_tree,TRUE) ;  /*Menüleiste anzeigen*/
  140.   rsrc_gaddr(R_TREE,KNOEPFE,&formular); /* Adresse des Formulars holen*/
  141.   strcpy(lspfile,"TEST.LSP"); /*Setze Default Lisp File*/
  142.   (((TEDINFO *)(formular[LISPFILE].ob_spec))->te_ptext)=lspfile; /*Objektkomponenete->te_ptext zeigt auf 
  143.                                                                   /* den String lispfile*/
  144.   form_center(formular,&dix,&diy,&diw,&dih);/*Zentriere das Formular*/
  145.   rsrc_gaddr(R_TREE,AUTOR,&urheber);/*Hol die Adresse der Infoschablone*/
  146.   form_center(urheber,&x_info,&y_info,&w_info,&h_info);   /*und zentriere sie*/
  147.   rsrc_gaddr(R_TREE,OPTFILES,&optfiles);/*Hol die Adresse der Hilfsfileschablone*/
  148.   (((TEDINFO *)(optfiles[NAME1].ob_spec))->te_ptext)=options[0];/*und verbiege alle Stringpointer*/
  149.   (((TEDINFO *)(optfiles[NAME2].ob_spec))->te_ptext)=options[1];/*sodaß sie auf die Strings für die*/
  150.   (((TEDINFO *)(optfiles[NAME3].ob_spec))->te_ptext)=options[2];/*Files zeigen*/
  151.   (((TEDINFO *)(optfiles[NAME4].ob_spec))->te_ptext)=options[3];
  152.   (((TEDINFO *)(optfiles[NAME5].ob_spec))->te_ptext)=options[4];
  153.   (((TEDINFO *)(optfiles[NAME6].ob_spec))->te_ptext)=options[5];
  154.   (((TEDINFO *)(optfiles[NAME7].ob_spec))->te_ptext)=options[6];
  155.   form_center(optfiles,&x_opt,&y_opt,&w_opt,&h_opt);/*Zentriere das Formular*/
  156.   wind_get(0,WF_WORKXYWH,&xfull,&yfull,&wfull,&hfull);/*Hol die Fensterkoordinaten*/
  157.   wikind[1]=NAME | INFO;/*FEnsterelemente festlegen*/
  158.   wind_calc(WC_WORK,wikind[1],xfull,yfull,wfull,hfull,&xwork,&ywork,&wwork,&hwork);/*Berechne Koordinaten*/
  159.                                                               /*für den Arbeitsbereich*/
  160.   maxwd=0;/* Ist angeblich für die FEnsterroutinen erforderlich*/
  161.   wd_init(handle);/*Initialisiere die Fensterroutinen der MM-Window_routinen*/
  162.   whandle[1]=wd_open(wikind[1],xwork,ywork,wwork,hwork);/*Öffne das Fenster*/
  163.   wd_title(whandle[1],"XLISPshell");/*Text für Titelzeile ausgeben*/
  164.   wd_info(whandle[1],"                                  \275 Dr. Sarnow");
  165.                                       /*Text für Infozeile ausgeben*/
  166.   wd_clr(whandle[1]);/*Lösche Fensterinhalt*/
  167.   wd_update(whandle[1]);/*Aktualisiere Fensterinhalt*/
  168.   multi() ;/*Verwaltet alle Ereignisse*/
  169.  
  170. }
  171.  
  172. multi()
  173. { int event,mx,my,dummy,keycode;
  174.  
  175.   do
  176.   { 
  177.        objc_draw(formular,0,MAX_DEPTH,dix,diy,diw,dih);/*Zeichne das Formular neu*/
  178.      event = evnt_multi(MU_KEYBD | MU_BUTTON | MU_MESAG,       /*Warten auf...*/
  179.                        1,1,1,
  180.                        FALSE,0,0,0,0,
  181.                        FALSE,0,0,0,0,
  182.                        msgbuff,0,0,
  183.                        &mx,&my,&dummy,&dummy,&keycode,&dummy) ;
  184.  
  185.     wd_redraw(msgbuff);/*Automatischer Redraw Befehl (MMTOOL4)*/
  186.  
  187.     if (event & MU_MESAG)    /*Menüleiste gewählt*/
  188.     { switch(msgbuff[0])
  189.       { case MN_SELECTED : do_menu(msgbuff[3],msgbuff[4]) ;
  190.                            break ;
  191.         
  192.       }
  193.     }
  194.  
  195.     /* weitere abfragen */
  196.    if (event & MU_BUTTON)
  197.    {
  198.       obval=objc_find(formular,0,MAX_DEPTH,mx,my);/*Finde angeklicktes Objekt*/
  199.       menu_bar(menu_tree,FALSE);/*Menüleiste aus*/
  200.       switch(obval)
  201.       {
  202.          case XLISP:/* Es war der XLISP-Knopf*/
  203.              wd_close(whandle[1]);/*Fenster dicht*/
  204.             curon(); /*Weg mit dem Desktop*/
  205.             strcpy(xlopt," ");                /*ERzeuge Parameterstring*/
  206.             xlopt=strcat(xlopt,lspfile);    /*für den XLISP Aufruf*/
  207.             for (dummy=0;dummy<7;dummy++)
  208.             {
  209.                if (strlen(options[dummy])>1)
  210.                {
  211.                   xlopt=strcat(xlopt," ");
  212.                   xlopt=strcat(xlopt,options[dummy]);
  213.                }
  214.             }
  215.             Pexec(0,"xlisp.ttp",xlopt,0L);    /*Los geht's*/
  216.             curoff();    /*Desktop wieder an*/
  217.             wd_display(whandle[1],xfull,yfull,wfull,hfull);/*Fenster auf*/
  218.             break;
  219.             
  220.          case EDITOR:        /*Wie bei XLISP*/
  221.              wd_close(whandle[1]);
  222.             strcpy(xlopt," ");
  223.             xlopt=strcat(xlopt,lspfile);
  224.             hide_mouse();
  225.             Pexec(0,"editor.prg",xlopt,0L);
  226.             show_mouse();
  227.             wd_display(whandle[1],xfull,yfull,wfull,hfull);
  228.             break;
  229.             
  230.          case OPTIONEN:    /*Wähle Optionsfile*/
  231.             keycode=opt();/*Welcher Button wird gedrückt?*/
  232.             strcpy(d,options[keycode]);                /*Auswahl erfolgt mit*/
  233.             strcpy(was," XLISP Hilfsfile wählen ");    /*Hilfe der File Selector-Routine*/
  234.             strcpy(akt," OK ");                        /*aus der MM-tool Diskette 4*/
  235.             file_select(pf,d,was,akt,"*.LSP","*.*","*.*","*.*",2);/*Aufruf derselben*/
  236.             strcpy(options[keycode],d);/*gewählte Datei festhalten*/
  237.             break;
  238.             
  239.          case LISPFILE:        /*Lisp Workfile wählen*/
  240.             strcpy(d,lspfile);/*sonst wie bei Options*/
  241.             strcpy(was," Lisp File wählen ");
  242.             strcpy(akt," OK ");
  243.             file_select(pf,d,was,akt,"*.LSP","*.*","*.*","*.*",2);
  244.             strcpy(lspfile,d);
  245.             break;
  246.             
  247.          case CIAO:    /*Tschüs, au revoir, good bye*/
  248.              wd_delete(whandle[1]);
  249.              rsrc_free();
  250.             show_mouse();
  251.             close_vwork();
  252.             break;
  253.       }
  254.       menu_bar(menu_tree,TRUE);
  255.    }
  256.   
  257.   }while(TRUE) ;
  258.  
  259. } /* multi */
  260.  
  261. do_menu(title,item)/*Routine führt die in der Menüleiste gewählte*/
  262. int title,item ;     /*Routine aus. Hat hier nicht viel zu tun*/
  263. { switch(title)
  264.   { case DESK  : 
  265.          switch(item)
  266.          { case INFORM : info() ; break ;
  267.          }
  268.    
  269.   }
  270.   menu_tnormal(menu_tree,title,1) ;/*Menütitel wieder normal zeichnen*/
  271.  
  272. } /* do menu */
  273.  
  274. info()     /*Zeige das Info-formular*/
  275. {       
  276.    form_dial(FMD_START,320,200,0,0,x_info,y_info,w_info,h_info);
  277.    form_dial(FMD_GROW,320,200,0,0,x_info,y_info,w_info,h_info);
  278.    objc_draw(urheber,0,20,x_info,y_info,w_info,h_info);
  279.    objc_change(urheber,INFOEX,0,x_info,y_info,w_info,h_info,(NORMAL | OUTLINED | SHADOWED),1);
  280.    form_do(urheber,0);
  281.    form_dial(FMD_SHRINK,320,200,0,0,x_info,y_info,w_info,h_info);
  282.    form_dial(FMD_FINISH,320,200,0,0,x_info,y_info,w_info,h_info);
  283. }
  284.  
  285. opt()    
  286. {       
  287.    int wahl;
  288.    char *str;
  289.    
  290.    form_dial(FMD_START,320,200,0,0,x_opt,y_opt,w_opt,h_opt);/*Zeige das Formular*/
  291.    form_dial(FMD_GROW,320,200,0,0,x_opt,y_opt,w_opt,h_opt); /*für die Wahl der Hilfs-*/
  292.    objc_draw(optfiles,0,20,x_opt,y_opt,w_opt,h_opt);        /*routinen*/
  293.    form_do(optfiles,0);
  294.    form_dial(FMD_SHRINK,320,200,0,0,x_opt,y_opt,w_opt,h_opt);
  295.    form_dial(FMD_FINISH,320,200,0,0,x_opt,y_opt,w_opt,h_opt);
  296.    wahl=dialog_wahl(optfiles,BUTTON1,BUTTON7);/*finde den gedrückten Knopf (aus MMtool 4)*/
  297.    objc_change(optfiles,wahl,0,x_opt,y_opt,w_opt,h_opt,NORMAL,0);/*Stelle ihn wieder normal dar*/
  298.    switch (wahl)    /*Leider haben nicht alle Objekte den gleiche Offset*/
  299.    {
  300.       case BUTTON1:
  301.          wahl=0;
  302.          break;
  303.  
  304.       case BUTTON2:
  305.          wahl=1;
  306.          break;
  307.          
  308.       case BUTTON3:
  309.          wahl=2;
  310.          break;
  311.  
  312.       case BUTTON4:
  313.          wahl=3;
  314.          break;
  315.  
  316.       case BUTTON5:
  317.          wahl=4;
  318.          break;
  319.  
  320.       case BUTTON6:
  321.          wahl=5;
  322.          break;
  323.  
  324.       case BUTTON7:
  325.          wahl=6;
  326.          break;
  327.  
  328.    }
  329.    return(wahl);
  330. }
  331.  
  332. curon()            /*Cursor an und Desktop ab*/
  333. {
  334.     graf_mouse(M_OFF,0L);
  335.     Cconout(0x1b);
  336.     Cconout('E');
  337.     Cconout(0x1b);
  338.     Cconout('e');
  339. }
  340.  
  341. curoff()        /*Cursor ab und Desktop an*/
  342. {
  343.     Cconout(0x1b);
  344.     Cconout('f');
  345.     graf_mouse(M_ON,0L);
  346. }
  347.